<?php
namespace app\shop\model;

use app\BaseModel;
use think\facade\Db;
class IndexAddress extends BaseModel
{
	//定义表名

	protected $name = 'longbing_card_shop_address';
    /**
     * @param $dis
     * @return array|string
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * 地址列表
     */
	public function addressList($dis,$page=10){
        $data = $this->where($dis)->paginate($page)->toArray();
        return $data;
    }

    /**
     * @param $data
     * 添加地址
     */
    public function addressAdd($data){
        $data['status'] =1;
        $data['create_time'] = time();
        $data['province']= !empty($data['province'])?$data['province']:'';
        $data['city']    = !empty($data['city'])?$data['city']:'';
        $data['area']    = !empty($data['area'])?$data['area']:'';
        $data['sex']     = !empty($data['sex'])?$data['sex']:'';
        $res = $this->insert($data);
        return $res;
    }

    /**
     * @param $dis
     * @param $data
     * @return IndexAddress
     * 编辑地址
     */
    public function addressUpdate($dis,$data){
        $data['update_time'] = time();
        $res = $this->where($dis)->update($data);
        return $res;
    }

    /**
     * @param $dis
     * @return array|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * 获取地址详情
     */
    public function addressInfo($dis){
        $data = $this->where($dis)->find();
        return $data;

    }



	


}